// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLAlterMaterializedViewStatement.h"
#include "../SQLExpr.h"
#include "../SQLName.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/listTran.h"

SQLAlterMaterializedViewStatement::SQLAlterMaterializedViewStatement()
{
  partitions = std::make_shared<std::list<SQLExpr_ptr>>();
}

SQLName_ptr SQLAlterMaterializedViewStatement::getName()
{
  return name;
}

void SQLAlterMaterializedViewStatement::setName(SQLName_ptr name)
{
  if (name != nullptr)
  {
    name->setParent(SharedObject(SQLAlterMaterializedViewStatement));
  }
  this->name = name;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefresh()
{
  return (refreshFast || refreshComplete || refreshForce || refreshOnDemand || refreshOnCommit || refreshStartWith || refreshNext || refreshOnOverWrite)?BOOL::TRUE:BOOL::FALSE;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshFast()
{
  return refreshFast;
}

void SQLAlterMaterializedViewStatement::setRefreshFast(BOOL_ptr refreshFast)
{
  this->refreshFast = refreshFast;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshComplete()
{
  return refreshComplete;
}

void SQLAlterMaterializedViewStatement::setRefreshComplete(BOOL_ptr refreshComplete)
{
  this->refreshComplete = refreshComplete;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshForce()
{
  return refreshForce;
}

void SQLAlterMaterializedViewStatement::setRefreshForce(BOOL_ptr refreshForce)
{
  this->refreshForce = refreshForce;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshOnCommit()
{
  return refreshOnCommit;
}

void SQLAlterMaterializedViewStatement::setRefreshOnCommit(BOOL_ptr refreshOnCommit)
{
  this->refreshOnCommit = refreshOnCommit;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshOnDemand()
{
  return refreshOnDemand;
}

void SQLAlterMaterializedViewStatement::setRefreshOnDemand(BOOL_ptr refreshOnDemand)
{
  this->refreshOnDemand = refreshOnDemand;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshOnOverWrite()
{
  return refreshOnOverWrite;
}

void SQLAlterMaterializedViewStatement::setRefreshOnOverWrite(BOOL_ptr refreshOnOverWrite)
{
  this->refreshOnOverWrite = refreshOnOverWrite;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshStartWith()
{
  return refreshStartWith;
}

void SQLAlterMaterializedViewStatement::setRefreshStartWith(BOOL_ptr refreshStartWith)
{
  this->refreshStartWith = refreshStartWith;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRefreshNext()
{
  return refreshNext;
}

void SQLAlterMaterializedViewStatement::setRefreshNext(BOOL_ptr refreshNext)
{
  this->refreshNext = refreshNext;
}

BOOL_ptr SQLAlterMaterializedViewStatement::getEnableQueryRewrite()
{
  return enableQueryRewrite;
}

void SQLAlterMaterializedViewStatement::setEnableQueryRewrite(BOOL_ptr enableQueryRewrite)
{
  this->enableQueryRewrite = enableQueryRewrite;
}

SQLExpr_ptr SQLAlterMaterializedViewStatement::getStartWith()
{
  return startWith;
}

void SQLAlterMaterializedViewStatement::setStartWith(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterMaterializedViewStatement));
  }
  this->startWith = x;
}

SQLExpr_ptr SQLAlterMaterializedViewStatement::getNext()
{
  return next;
}

void SQLAlterMaterializedViewStatement::setNext(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterMaterializedViewStatement));
  }
  this->next = x;
}

BOOL_ptr SQLAlterMaterializedViewStatement::isRebuild()
{
  return rebuild;
}

void SQLAlterMaterializedViewStatement::setRebuild(BOOL_ptr rebuild)
{
  this->rebuild = rebuild;
}

SQLExpr_list_ptr SQLAlterMaterializedViewStatement::getPartitions()
{
  return partitions;
}

// @Override
void SQLAlterMaterializedViewStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterMaterializedViewStatement)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, startWith);
    acceptChild(visitor, next);
    SQLObject_list_ptr tmp1 = ListTran::tran_class<SQLExpr, SQLObject>(partitions);
    acceptChild(visitor, tmp1);
  }
  visitor->endVisit(SharedObject(SQLAlterMaterializedViewStatement));
}

// @Override
SQLDDLStatement::DDLObjectType SQLAlterMaterializedViewStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::MATERIALIZED_VIEW;
}
